<?php
/**
 * 修改密码
 */

class PasswordAction extends AdAction
{
    /**
     * 构造函数
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     *
     */
    public function index()
    {
        $form = I('post.');

        if ($form) {
            $map['enterprise_id']   = $form['enterprise_id'];
            $map['password']        = encryptionPwd($form['password']);
            $res = M('enterprise')->where($map)->find();
            if ($form['new_password'] != $form['confirm_password']) {
                alert('error','两次密码输入不一致');
            }
            if (!$res) {
                alert('error','原密码错误');
            }

            $data['password'] = encryptionPwd($form['new_password']);
            $rs = M('enterprise')->where($map)->save($data);
            if ($rs) {
                alert('success','密码修改成功');
            }
        }

        $this->display();

    }


}



?>